scoreboard objectives add rmr.local.self_uuid_0 dummy
scoreboard objectives add rmr.local.self_uuid_1 dummy
scoreboard objectives add rmr.local.self_uuid_2 dummy
scoreboard objectives add rmr.local.self_uuid_3 dummy

execute store result score @s rmr.local.self_uuid_0 run data get entity @s UUID[0]
execute store result score @s rmr.local.self_uuid_1 run data get entity @s UUID[1]
execute store result score @s rmr.local.self_uuid_2 run data get entity @s UUID[2]
execute store result score @s rmr.local.self_uuid_3 run data get entity @s UUID[3]

execute if score @s rmr.local.self_uuid_0 = @n[tag=rmr.connect.owned] rmr.connect.owner_uuid_0 if score @s rmr.local.self_uuid_1 = @n[tag=rmr.connect.owned] rmr.connect.owner_uuid_1 if score @s rmr.local.self_uuid_2 = @n[tag=rmr.connect.owned] rmr.connect.owner_uuid_2 if score @s rmr.local.self_uuid_3 = @n[tag=rmr.connect.owned] rmr.connect.owner_uuid_3 run tag @s add rmr.connect.owner

scoreboard objectives remove rmr.local.self_uuid_0
scoreboard objectives remove rmr.local.self_uuid_1
scoreboard objectives remove rmr.local.self_uuid_2
scoreboard objectives remove rmr.local.self_uuid_3